<header class="header">
    <div class="fix_nav">
        <div class="nav_inner">
            <a class="nav-left back-icon" href="/member/order/index.html">返回</a>
            <div class="tit">订单激活</div>
        </div>
    </div>
</header>
<div class="container mb50">
    <div class="row">
        <ul class="list-group">
            <li class="list-group-item text-primary">订单编号：<?=$order['sn']?></li>
            <?php foreach ($order['products'] as $item):?>
                <li class="list-group-item hproduct clearfix ">
                <div class="list-group_12">
                    <div class="p-pic">
                        <a href="/product/detail/goods_id/<?=$item['product_id']?>.html">
                            <img src="<?=$item['product_thumb']?>" alt="<?= $item['product_name']?>" class="img-responsive">
                        </a>
                    </div>
                    <div class="p-info">
                        <a href="/product/detail/goods_id/<?=$item['product_id']?>.html">
                            <p class="p-title"><?= $item['product_name']?></p>
                            <p class="p-origin">
                                <em class="price">¥<?=price_format($item['price'])?></em>
                            </p>
                        </a>
                    </div>
                </div>
                </li>
            <?php endforeach;?>
            <li class="list-group-item clearfix ">
                <p class="mb0">
                    <span>订单金额:￥</span><em class="price"><?=price_format($order['amount'])?></em>
                </p>
            </li>
        </ul>
    </div>

    <div class="row" style="background: #fff; padding: 20px 0 10px 0;">

        <div class="col-md-12">

            <form class="form-horizontal">
                <?php if($cate_id != '31' && $cate_id != '33'):?>
                    <p class="alert alert-danger">
                        根据国家对预付卡监管要求，需要登记购卡者的姓名和身份证号。您可以凭着登记的手机号码在加油站的POS上输入交易密码就可以加油消费。
                    </p>
                <div class="form-group">
                    <label for="consignee" class="col-sm-2 control-label">持卡人</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" id="consignee" name="consignee" placeholder="请填写姓名" value="<?=$address['consignee']?>">
                    </div>
                </div>
                <div class="form-group">
                    <label for="idnum" class="col-sm-2 control-label">身份证号</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" id="idnum" name="idnum" placeholder="请填写身份证号" value="<?=$address['idnum']?>">
                    </div>
                </div>
                <?php else:?>
                    <input type="hidden" id="consignee" name="consignee" value="<?=$address['consignee']?>" />
                    <input type="hidden" id="idnum" name="idnum" value="<?=$address['idnum']?>" />
                <?php endif;?>

                <div class="form-group">
                    <label for="mobile" class="col-sm-2 control-label">手机号码</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" id="mobile" name="mobile" placeholder="请填写手机号码" value="<?=$address['mobile']?>">
                    </div>
                </div>
                <div class="form-group">
                    <label for="r_mobile" class="col-sm-2 control-label">确认手机号码</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" id="r_mobile" name="r_mobile" placeholder="请再次填写手机号码" value="<?=$address['mobile']?>">
                    </div>
                </div>
                
                <div class="pay_area" id="pay_area" style="-webkit-transform-origin: 0px 0px; opacity: 1; -webkit-transform: scale(1, 1);">
                    <p class="use_pay">
                        <button type="button" class="btn btn-warning btn-block mt10" id="sb_btn" > 激 活 </button>
                    </p>
                    <input type="hidden" name="order_sn" id="order_sn" value="<?=$item['sn']?>"/>
                </div>
            </form>
        </div>
    </div>
</div>
<script>
//激活
$('#sb_btn').click(function(){
    var address_id = $('input#address_id').val();
    var consignee = $.trim($("input#consignee").val());
    var mobile = $.trim($("input#mobile").val());
    var r_mobile = $.trim($("input#r_mobile").val());
    var idnum = $.trim($("input#idnum").val());
    var order_sn = $.trim($("#order_sn").val());

    <?php if($cate_id != '31' && $cate_id != '33'):?>
    if(consignee == ''){
        floatNotify.simple('请输入持卡人姓名!');
        return false;
    }
    if(idnum == ''){
        floatNotify.simple('请输入持卡人身份证号!');
        return false;
    }
    <?php endif;?>

    if(mobile == ''){
        floatNotify.simple('请输入持卡人手机号码!');
        return false;
    }

    if(!/^(1[0-9])\d{9}$/i.test(mobile))
    {
        floatNotify.simple('手机号码不合法！');
        return false;
    }

    if(r_mobile != mobile){
        floatNotify.simple('两次手机号码输入不一致!');
        return false;
    }

    $('#sb_btn').attr('disabled', true);
    $.post('/member/order/activate.html?'+Math.random(),
        {
            order_sn:order_sn,
            address_id:address_id,
            consignee:consignee,
            mobile:mobile,
            idnum:idnum,
            cate_id:'<?=$cate_id?>'
        },
        function(res){

            $(".ui-loader").remove();
            floatNotify.simple(res.msg,2000);

            if(res.status == 1){
                 setTimeout(function(){
                     location.href=res.url;//页面直接跳转
                 },2000)
            }else{
                $('#sb_btn').attr('disabled', false);
            }
    },'json');
});
</script>
